package com.tos.second.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.tos.second.dto.GoodsSearchDto;
import com.tos.second.entity.Goods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsMapper extends BaseMapper<Goods> {

    // 查询商品列表
    Page<Goods> pageQuery(Long categoryId);

    void saveUser(Goods goods);

    @Select("select * from goods where id = #{id}")
    Goods getGoodsById(Long id);


    void updateGoods(Goods goods);

    @Select("select * from goods where create_user = #{currentId} order by create_time desc")
    List<Goods> getMyGoods(Long currentId);

    @Select("select * from goods where status = 1 order by goods.create_time desc limit 12")
    List<Goods> getNewGoods();

    List<Goods> getGoodsByName(GoodsSearchDto goodsSearchDto);


    List<Goods> getGoodsByCategoryId(Long categoryId);

    List<Goods> getGoodsByCategoryIdLimitNine(Long categoryId);
}
